package shuishijie.suishijie.model;

import android.text.TextUtils;

import shuishijie.suishijie.util.AppUtil;


/**
 * Created by mindx on 2017/8/29.
 */

public class CommonData {
    public static final String PAGE_COUNT = "10";
    private static int msgCount;

    public static String getMobile() {
        return mobile;
    }

    static String mobile;
    static String user_id;
    static String shop_id;
    static String token;

    public static ShopInfo getShopInfo() {
        if (shopInfo == null) {
            shopInfo = new ShopInfo();
        }
        return shopInfo;
    }

    private static ShopInfo shopInfo;

    public static void setShopInfo(ShopInfo shopInfo) {
        CommonData.shopInfo = shopInfo;
    }

    public static void setMsgCount(int msgCount) {
        CommonData.msgCount = msgCount;
    }

    public static int getMsgCount() {
        return msgCount;
    }

    public static boolean isCurrentUser(String user_id) {
        return isCurrentUser(AppUtil.parseInt(user_id));
    }

    public static boolean isCurrentUser(int user_id) {
        return TextUtils.equals("" + user_id, CommonData.user_id);
    }


    public static void setUserInfo(UserInfo data) {
        if (data != null) {
            mobile = data.phone;
            user_id = String.valueOf(data.user_id);
            shop_id = String.valueOf(data.shop_id);
            token = String.valueOf(data.token);
        } else {
            mobile = null;
            user_id = null;
            shop_id = null;
            token = null;
        }
    }

    public static boolean isLogin() {
        return !TextUtils.isEmpty(mobile);
    }

    public static void setToken(String token) {
        CommonData.token = token;
    }

}
